package com.nf.controller.home;

import com.google.gson.Gson;
import com.nf.controller.BaseServlet;
import com.nf.dao.TicketVoDao;
import com.nf.dao.impl.TicketVoDaoImpl;
import com.nf.vo.TicketVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 编写servlet ，实现根据放映ID 查询其放映场次的相关信息（多表查询）
 */
@WebServlet("/api/SelectTicketInfoByShowIdServlet.do")
public class SelectTicketInfoByShowIdServlet extends BaseServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int showId= Integer.parseInt(req.getParameter("showId"));

        TicketVoDao dao=new TicketVoDaoImpl();
        TicketVo tik= dao.selectTicket(showId);

        resp.setContentType("application/json;charset=utf-8");
        PrintWriter out = resp.getWriter();

        out.print(new Gson().toJson(successJson(tik)));

        out.flush();
        out.close();
    }
}
